package com.api.shopapi.service.impl;

import com.api.shopapi.entity.ElderlyClockin;
import com.api.shopapi.entity.dto.ElderlyClockinDTO;
import com.api.shopapi.mapper.ElderlyClockinMapper;
import com.api.shopapi.service.ElderlyClockinService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service("ElderlyClockinServiceImplOne")
public class ElderlyClockinServiceImpl implements ElderlyClockinService {

    @Autowired
    private ElderlyClockinMapper elderlyClockinMapper;

    @Override
    public int insert(ElderlyClockin elderlyClockin) {
        return elderlyClockinMapper.insert(elderlyClockin);
    }

    @Override
    public PageInfo<ElderlyClockinDTO> getPageList(int pageIndex, int pageSize, String governmentCode, String zoneCode, Date startTime, Date endTime, String idCard, String name) {
        PageHelper.startPage(pageIndex,pageSize);
        List<ElderlyClockinDTO> elderlyClockinList=elderlyClockinMapper.getPageList(governmentCode,
                zoneCode,startTime,endTime,idCard,name);
        return new PageInfo<>(elderlyClockinList);
    }

    @Override
    public List<ElderlyClockinDTO> getList(String governmentCode, String zoneCode, Date startTime, Date endTime, String idCard, String name) {
        return elderlyClockinMapper.getPageList(governmentCode, zoneCode,startTime,endTime,idCard,name);
    }

    @Override
    public
    PageInfo<ElderlyClockinDTO> getForPageForServe(int pageIndex, int pageSize, String serveCode){
        PageHelper.startPage(pageIndex,pageSize);
        List<ElderlyClockinDTO> list=elderlyClockinMapper.getForPageForServe(serveCode);
        return new PageInfo<>(list);
    }

}
